<template>
  <div>
    <div class="header">
    <van-nav-bar
        title="修改密码"
        left-arrow
        @click-left="$router.back()"
      >
        <template #left>
          <van-icon name="arrow-left" size="26" color="#000" />
        </template>
      </van-nav-bar>
      </div>
      <div class="main">
         <van-cell-group border>
    <van-field v-model="password" type="password" label="输入当前密码" />
    <van-field v-model="password1" type="password" label="修改后的密码"  />
     </van-cell-group>
    <div class="buto">
     <van-button type="danger" round block  @click="next"
        >下一步</van-button>
        </div>
      </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
import {doUpDate  } from "../api/user";
export default {
data () {
    return {
        password:"",
        password1:""
    }
},
methods: {
    next(){
        doUpDate({userid:localStorage.getItem("userid"),oldpassword:this.password,newpassword:this.password1}).then((res)=>{
            if(res.data.code=="10030"){
                Toast("您输入的旧密码不正确，请重新输入")
            }else{
                Toast("修改成功")
                this.$router.push("/login")
            }
        })
    }
}
}
</script>

<style scoped>
.main{
    margin: .2rem 0;
}
.van-field {
    width: 100%;
    height: .5rem;
    font-size: .2rem;
    background: rgb(225, 222, 222);
    margin: .1rem 0;
    
}
.buto{
      width: 80%;
  margin: 20px auto;
}
</style>